<p><h1>Listing posts</h1></p>

<%= form_tag(posts_url, :class => 'well form-search', :method => :get) do %>
  <%= text_field_tag :search, params[:search], :placeholder => "Search" %>
  <%= submit_tag "search", :class => 'btn' %>
<% end %>

<% if @posts and @posts.any? %>
  <table class="table table-bordered table-striped">
    <tr>
      <th>Author</th>
      <th>Post</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>

    <% @posts.each do |post| %>
      <tr>
        <td><%= post.user.username %></td>
        <td><%= post.body %></td>
        <td><%= link_to 'Show', post %></td>
      </tr>
    <% end %>
  </table>
<% else %>
  <div>No posts found</div>
<% end %>

<br />

<%= link_to 'New Post', new_post_path %>